<?php
    include('config.ini.php');
    include(ADMINPATH.'/classes/adodb5/adodb.inc.php');
    include(ADMINPATH.'/include/db.connect.php');
    include(ADMINPATH.'/include/function.php');
    
    if(isset($_POST['name'])){
	
	if($_POST['name']==''){
	    alert('Please enter your name.');
	}else{
	    if($_POST['email']==''){
		alert('Please enter your e-mail.');
	    }else{
                $html_mail =  '<strong>Name - Surname : </strong>'.$_POST['name'];
                $html_mail .=  '<br /><strong>E-mail : </strong>'.$_POST['email'];
                $html_mail .=  '<br /><strong>Tel : </strong>'.$_POST['tel'];
                $html_mail .=  '<br /><strong>Address : </strong><br />'.$_POST['address'];
                
                $to      = CONTACT_EMAIL;
                
                $subject = 'New subscribe member.';
                $message = $html_mail;
        
                $headers  = 'MIME-Version: 1.0' . "\r\n";
                $headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";
                $headers .= "From: $email" . "\r\n" .
                        "Reply-To: $email" . "\r\n" .
                        'X-Mailer: PHP/' . phpversion();
        
                $result = @mail($to, $subject, $message, $headers);
                if($result){
                    $sql = "INSERT INTO subscribe(s_name,s_email,s_tel,s_address) VALUES('".$_POST['name']."','".$_POST['email']."','".$_POST['tel']."','".$_POST['address']."')";
                    $result = $db->Execute($sql);
                }
                alert('Thank you for subscribe me.');
                echo '<script>top.location.reload();</script>';
	    }
	}
    }
?>

<style>
    .form_field{
        clear:left;
        width:500px;
        font-family:'tahoma';
        font-size:13px;
    }
    .form_field label{
        float:left;
        width:150px;
    }
    .form_field .input{
        font-family:'tahoma';
        font-size:13px;
        width:350px;
    }
    .form_field textarea{
        width:350px;
        height:120px;
    }
    .form_field_{
        margin-top:10px;
    }
    #ajaxIframe{
        height:0;
        display:none;
    }
</style>
<form action="subscribe.php" method="post" target="ajaxIframe">
<div class="form_field">
    <label>Name : </label>
    <input type="text" name="name" class="input" /> <span style="color:red;">*</span>
</div>
<div class="form_field">
    <label>E-mail : </label>
    <input type="text" name="email" class="input" /> <span style="color:red;">*</span>
</div>
<div class="form_field">
    <label>Tel. : </label>
    <input type="text" name="tel" class="input" /> <span style="color:red;">*</span>
</div>
<div class="form_field">
    <label>Address : </label>
    <textarea name="address"></textarea>
</div>
<div class="form_field">
    <label>&nbsp;</label>
</div>
<div class="form_field_">
    <input type="submit" class="contact_info_from_bt" value="Submit" />
    <input type="reset" class="contact_info_from_bt" value="Clear" />
</div>
</form>
<iframe name="ajaxIframe" id="ajaxIframe"></iframe>